﻿namespace h66
{
    public class Solution {
        public double FindMaxAverage(int[] nums, int k) {
            if (nums.Length == 1)
            {
                return nums[0];
            }
            int sum = 0;
            double max = 0;
            for (int i = 0; i < k; i++)
            {
                sum += nums[i];
            }
            max = sum;
            for (int i =0;i<nums.Length-k;i++)
            {
                sum = sum - nums[i] + nums[i + k];
                if (max < sum) { max = sum; }
            }
            double res = max / k;
            return res ;
        }
    }

}